package com.koron.dynamic.controller;

import com.koron.bean.app.AppBean;
import com.koron.bean.base.Response;
import com.koron.dynamic.koronDataSource.KrDataSourceUtils;
import com.koron.dynamic.service.KrDataSourceService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName KrDataSourceController
 * @description
 * @Author zhouj
 * @Date 2021/7/15 20:18
 */
@RestController
@RequestMapping("/krds")
@Api(tags = "数据源管理")
public class KrDataSourceController {

    @Autowired
    KrDataSourceService krDataSourceService;

    @GetMapping("/registrySingleDb")
    public Response<String> registrySingleDb(AppBean appBean){
        KrDataSourceUtils.registDb(appBean);
        return Response.ok();
    }

    @GetMapping("/removeEnvSource")
    public Response<String> removeEnvSource(@RequestParam("env") String env){
        KrDataSourceUtils.removeEnvSource(env);
        return Response.ok();
    }

    /*
     * 功能描述 注册数据源
     * @author zhouj
     * @date 2021/7/19 17:36
     * @param
     * @return
     */
    @GetMapping("/registryDb")
    public Response<String> registryMultDb(@RequestParam("markList") List<String> markList){
        krDataSourceService.registryMultDb(markList);
        return Response.ok("");
    }

}
